package com.ssii.www.myproject.service.impl;

import com.ssii.www.myproject.domain.Task;
import com.ssii.www.myproject.repository.TaskRepository;
import com.ssii.www.myproject.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class TaskServiceImpl extends BaseServiceImpl<Task, Long> implements TaskService {

  @Autowired
  private TaskRepository taskRepository;

//  @Override
//  @Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
//  public Task findTaskByApplyCode(String applycode) {
//    Task task = taskRepository.findTaskByScode(applycode);
//    return task;
//  }

  @Override
  public List<Task> findTasksByApplyCode(String applycode) {
    return taskRepository.findTasksByApplycode(applycode);
  }

  @Override
  public void save(Task task) {
    //新增任务 设置状态
    if (task != null && task.getState() == null) {
      task.setState(1L);
    }
    taskRepository.save(task);
  }


}
